#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Src/Services/Product.API/Product.API.csproj", "Src/Services/Product.API/"]
COPY ["Src/Services/Open.Product.Application/Open.Product.Application.csproj", "Src/Services/Open.Product.Application/"]
COPY ["Core/Open.Domain/Open.Domain.csproj", "Core/Open.Domain/"]
COPY ["Core/Open.Core/Open.Core.csproj", "Core/Open.Core/"]
COPY ["Src/BuildingBlocks/SDK/SDK.SqlSugar/SDK.SqlSugar.csproj", "Src/BuildingBlocks/SDK/SDK.SqlSugar/"]
COPY ["Src/BuildingBlocks/SDK/SDK.Core/SDK.Core.csproj", "Src/BuildingBlocks/SDK/SDK.Core/"]
COPY ["Src/Services/Open.Product.Domain/Open.Product.Domain.csproj", "Src/Services/Open.Product.Domain/"]
COPY ["Src/BuildingBlocks/EF/LogicApi.EntityFrameworkCore/LogicApi.EntityFrameworkCore.csproj", "Src/BuildingBlocks/EF/LogicApi.EntityFrameworkCore/"]
RUN dotnet restore "Src/Services/Product.API/Product.API.csproj"
COPY . .
WORKDIR "/src/Src/Services/Product.API"
RUN dotnet build "Product.API.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Product.API.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Product.API.dll"]